<template>
    <div class="order-detail">
        <h2>订单详情</h2>
        <div v-if="orderDetailData">
            <p>订单号: {{ orderDetailData.orderNo }}</p>
            <p>下单时间: {{ orderDetailData.orderTime }}</p>
            <p>联系电话: {{ orderDetailData.phone }}</p>
            <p>收货人: {{ orderDetailData.consignee }}</p>
            <p>送货地址: {{ orderDetailData.deliverAddress }}</p>
            <p>送达时间: {{ orderDetailData.deliveryTime }}</p>
            <p>备注: {{ orderDetailData.remarks }}</p>
            <p>订单金额: {{ orderDetailData.orderAmount }}</p>
            <p>订单状态: {{ orderDetailData.orderState }}</p>
        </div>
    </div>
</template>

<script setup>
import { ref, onMounted } from 'vue';
import { useRoute } from 'vue-router';
import { detailOrder } from '../../api/account';

const route = useRoute();
const orderDetailData = ref(null);

const fetchOrderDetail = async () => {
    const id = route.params.id;
    try {
        const response = await detailOrder(id);
        orderDetailData.value = response.data;
    } catch (error) {
        console.error('Error fetching order detail:', error);
    }
};

onMounted(() => {
    fetchOrderDetail();
});
</script>

<style lang="scss" scoped>
.order-detail {
    padding: 20px;
    background-color: #fff;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
    padding: 0;
    margin: 0;
    p{
        margin: 10px 0;
        font-size: 16px;
        color: #333;
        height: 20px;
        line-height: 20px;
    }
}

</style>